import { UserLoginout } from '@/api/user';
import { Cell } from '@antmjs/vantui';
import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import './index.less';

export default function Page() {
  return (
    <View className=' min-h-screen overflow-hidden p-4'>
      <Cell
        renderIcon={
          <View
            className='w-[28px] h-[28px] bg-cover mr-1'
            style={{
              backgroundImage: `url(https://applets-1302975996.cos.ap-nanjing.myqcloud.com/zhb/icon-loginout.svg)`,
            }}
          />
        }
        title='退出登录'
        isLink
        border={false}
        className=' border-4 border-gary5 border-solid rounded-lg overflow-hidden'
        onClick={async () => {
          Taro.showModal({
            title: '退出登录',
            content: '确定要退出登录吗？',
            success: async ({ confirm }) => {
              if (confirm) {
                await UserLoginout();
                Taro.clearStorageSync();
                Taro.reLaunch({
                  url: '/pages/login/role',
                });
              }
            },
          });
        }}
      />
    </View>
  );
}
